package za.um.td.prototyping;

import za.um.td.entity.Placable;

import com.jme.bounding.BoundingBox;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;

public class UberTower extends Placable {

	public UberTower(String id) {
		super(id);

		placeBlocks = new Vector2f[4];

		placeBlocks[0] = new Vector2f(0, 0);
		placeBlocks[1] = new Vector2f(1, 0);
		placeBlocks[2] = new Vector2f(1, 1);
		placeBlocks[3] = new Vector2f(0, 1);

		numBlocksX = numBlocksZ = 1;
		
		shootRadius = 20f;

		initSpatial();

	}

	private void initSpatial() {
		Node spatial = new Node();

		Box uberBox = new Box("UberBox:" + getId(),
				new Vector3f(0.5f, 2f, 0.5f), numBlocksX - 0.1f, 2f,
				numBlocksZ - 0.1f);

		uberBox.setSolidColor(ColorRGBA.blue);

		ZBufferState buf = DisplaySystem.getDisplaySystem().getRenderer()
				.createZBufferState();
		buf.setEnabled(true);
		buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
		spatial.setRenderState(buf);
		spatial.updateRenderState();

		spatial.setModelBound(new BoundingBox());
		spatial.updateModelBound();

		spatial.attachChild(uberBox);
		setSpatial(spatial);
	}

}
